Learn Python Visually: An Accelerated Method Which Uses Science and Creativity to Teach the Right Brain Non-Coders (Learn Visually) by Ivelin Demirov

Learn Python Visually: An Accelerated Method Which Uses Science and Creativity to Teach the Right Brain Non-Coders (Learn Visually) by Ivelin Demirov

Author:Ivelin Demirov
Language: eng
Format: mobi, epub, pdf
Published: 2015-05-27T18:30:00+00:00


numbers = [1, 2, 5, 6, 7, 8, 9]

for number in numbers:

print(“Looking at: “ + str(number))

if number > 6:

print(“Too big: “ + str(number) + “!”)

break

The above code gives the following output:

Looking at: 1

Looking at: 2

Looking at: 5

Looking at: 6

Looking at: 7

Too big: 7!

The iteration stops after number 7, meaning that numbers 8 and 9 are not included.

You can also skip particular items in a collection using the “continue” keyword:

numbers = [1, 6, 7, 8, 9, 2, 5]

for number in numbers:

if number > 6:

continue

print(“Looking at: “ + str(number))



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.